#ifndef _WWWSRVCONNMANAGER_HXX_
#define _WWWSRVCONNMANAGER_HXX_

#include <mytypes.h>
#include <mymutex.hxx>
#include <mythread.hxx>
#include <safeque.hxx>
#include <bridgemessage.hxx>

#include <vector>
#include <map>
#include <set>

class FileLog;
class AuConn;
class TcpSocket;
class AtkConnManager;

using namespace std;

class AuConnManager : public Thread
{
public:
  typedef vector<AuConn*> tAuConnVec;
  
  AuConnManager(tUInt32 auport, AtkConnManager*atkconn_manager, FileLog *filelog=0);
  ~AuConnManager();

  void Shutdown(void);

  void SendToAttackers(const tBridgeMsg* bmsg);

  void SendToAutoers(const tBridgeMsg* bmsg, const AuConn* except);

protected:
  virtual void Execute(Thread::Arg arg);

private:
  AuConnManager(const AuConnManager &model);

  void ClearConns(bool last = false);

  tAuConnVec _auconn_vec;
  Mutex _auconn_vec_mutex;
  
  tUInt32 _auport;
  
  //By which request messages can be forwarded to AtkConnManager
  AtkConnManager* _atkconn_manager;
  
  std::set<string> _proxies;
  Mutex _proxies_mutex;
  bool _is_shutdown_requested;
  FileLog *_filelog;
};

#endif // _WWWSRVCONNMANAGER_HXX_
